$(function(){
    $(".btn-active").click(function (event) {
        event.preventDefault()
        $this = $(this)
        var is_active = parseInt($this.attr("data-is-active"))
        var board_id = parseInt($this.attr("data-board-id"))
        data={
            'is_active':is_active?0:1
        }
        $.ajax({
            url:"/cms/board/active/"+board_id,
            data:data,
            method:"PUT",
            success:function (res) {
                alert("上线成功")
                window.location.reload()
            },
            fail:function (err) {
                alert(err)
            }
        })
    })
    $(".btn-edit").click(function (event) {
        event.preventDefault()
        $this = $(this)
        board_name = $this.attr("data-board-name")
        board_id = $this.attr("data-board-id")
        $("#exampleInput1").val(board_name)
        $("#exampleInput1").attr("data-board-id",board_id)
    })
    $("#btn-edit-name").click(function (event) {
        event.preventDefault()
        board_name = $("#exampleInput1").val()
        board_id = $("#exampleInput1").attr("data-board-id")
        console.log(board_name+'-------'+board_id)
        $.ajax({
            url:'/cms/board/name/'+board_id,
            data:{"board_name":board_name},
            method: "PUT",
            success:function () {
                alert("分类修改成功")
                window.location.reload()
            }
        })
    })
})